$(document).ready(function(){					
	var canvas = document.getElementById('canvas');
	var stage = new JTopo.Stage(canvas);
	var scene = new JTopo.Scene(stage);
    scene.background = './img/bg.jpg';
	
    function node(x, y, img){
        var node = new JTopo.Node();
        node.setImage('./img/statistics/' + img, true);                
        node.setLocation(x, y);
        scene.add(node);
        return node;
    }    
	
    
    function linkNode(nodeA, nodeZ, f){
        var link;
        if(f){
            link = new JTopo.FoldLink(nodeA, nodeZ);
        }else{
            link = new JTopo.Link(nodeA, nodeZ);
        }
        link.direction = 'vertical';
        scene.add(link);
        return link;
    }
    
    var s1 = node(305, 43, 'server.png'); s1.alarm = '2 W';
    var s2 = node(365, 43, 'server.png');
    var s3 = node(425, 43, 'server.png');
   
    var g1 = node(366, 125, 'gather.png');
    linkNode(s1, g1, true);
    linkNode(s2, g1, true);
    linkNode(s3, g1, true);
    
    var w1 = node(324, 167, 'wanjet.png');
    linkNode(g1, w1);
    
    var c1 = node(364, 214, 'center.png');
    linkNode(w1, c1);
    
    var cloud = node(344, 259, 'cloud.png');
    linkNode(c1, cloud);
    
    var c2 = node(364, 328, 'center.png');
    linkNode(cloud, c2);
    
    var w2 = node(324, 377, 'wanjet.png');
    linkNode(c2, w2);
    
    var g2 = node(366, 411, 'gather.png');
    linkNode(w2, g2);
    
    function hostLink(nodeA, nodeZ){                
        var link = new JTopo.FlexionalLink(nodeA, nodeZ);                
        link.shadow = false;
        link.offsetGap = 44;
        scene.add(link);
        return link;
    }
    
    var h1 = node(218, 520, 'host.png');
    h1.alarm = '';
    hostLink(g2, h1);
    var h2 = node(292, 520, 'host.png');
    hostLink(g2, h2);
    var h3 = node(366, 520, 'host.png');
    h3.alarm = '二级告警';
    hostLink(g2, h3);
    var h4 = node(447, 520, 'host.png');
    hostLink(g2, h4);
    var h5 = node(515, 520, 'host.png');
    h5.alarm = '1M';
    hostLink(g2, h5);
    
    setInterval(function(){
        if(h3.alarm == '二级告警'){
            h3.alarm = null;
        }else{
            h3.alarm = '二级告警'
        }
    }, 600);
    
});
	